<template>
  <a-modal
    :title="'单位及项目统计'"
    :width="drawerWidth"
    :visible="visible"
    :destroyOnClose="true"
    :footer="null"
    @cancel="handleCancel"
    cancelText="关闭">
    <div class="table-page-search-wrapper">
      <a-form-model
        ref="ruleForm"
        layout="inline"
        :model="formInfo"
        :label-col="$global.labelCol"
        :wrapper-col="$global.wrapperCol"
      >
        <a-row :gutter="12">
          <a-col :md="4" :sm="8">
            <a-form-item
              label="单位名称"
              :maxLength="50">
              <a-input :maxLength="50" placeholder="请输入单位名称" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="$refs.table.refresh(true)" icon="search">查询</a-button>
              <a-button
                @click="() => {this.$objToReset(queryParam),$refs.table.refresh(true)}"
                icon="reload"
                style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
        <s-table
          ref="table"
          rowKey="id"
          size="middle"
          :scroll="{ x: 1300 }"
          :columns="columns"
          :data="loadData">
          <template slot="action" slot-scope="text, record">
            <a-button type="primary" @click="haldelAdd(record.id)">加入</a-button>
          </template>
        </s-table>
      </a-form-model>
    </div>
  </a-modal>
</template>

<script>

  import moment from 'moment'
  import { postAction } from '@/api/manage'
  import { STable, Ellipsis } from '@/components'
  import { baseMixin } from '@/store/app-mixin'
  import WxFilterDepart from '@/components/WxFilterDepart/WxFilterDepart'

  export default {
    name: 'TalentAdd',
    mixins: [baseMixin],
    components: { STable, Ellipsis, WxFilterDepart },
    data () {
      return {
        drawerWidth: document.body.clientWidth - 200,
        visible: false,
        toggleSearchStatus: true,
        // 查询条件
        queryParam: {
          name: ''
        },
        formInfo: {},
        // 表头
        // 如果需要字典，那么需要在columns列中加入 customRender: (text) => this.$sysDictFilter(text, 'xxxx')xxxx 为dataIndex
        columns: [
          {
            title: '单位名称',
            dataIndex: 'corpName'
          },
          {
            title: '项目总数量',
            dataIndex: 'proNum'
          },
          {
            title: '筹备',
            dataIndex: 'choubei'
          },
          {
            title: '在建',
            dataIndex: 'zaijian'
          },
          {
            title: '已完工',
            dataIndex: 'wangong'
          },
          {
            title: '人数',
            dataIndex: 'totalNum'
          }
        ],
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          return postAction(this.url.list, Object.assign((parameter || {}), this.queryParam))
            .then(res => {
              return res.result
            })
        },
        url: {
          list: '/system/homePageStatistic/corpStatistic'
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        this.visible = true
      },
      moment,
      handleCancel () {
        this.visible = false
      }
    }
  }
</script>
